﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevComponents.DotNetBar;

namespace PlanningGIS.Product
{
    /// <summary>
    /// 需要自动更新的属性列
    /// </summary>
    public partial class FrmAutoField : Office2007Form
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public FrmAutoField(List<string> fields)
        {
            InitializeComponent();
            allFields = fields;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FrmAutoField_Load(object sender, EventArgs e)
        {
            if (allFields == null || allFields.Count == 0)
                return;
            listView.Items.Clear();
            foreach (string str in allFields)
            {
                listView.Items.Add(str);
            }
        }
        /// <summary>
        /// 
        /// </summary>
        public List<string> CheckedFields { get; private set; }
        /// <summary>
        /// 
        /// </summary>
        private List<string> allFields = null;

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCheckAll_Click(object sender, ClickEventArgs e)
        {
            for (int i = 0; i < listView.Items.Count; i++)
            {
                listView.Items[i].Checked = true;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnNoCheckAll_Click(object sender, ClickEventArgs e)
        {
            for (int i = 0; i < listView.Items.Count; i++)
            {
                listView.Items[i].Checked = false;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCheckSel_Click(object sender, ClickEventArgs e)
        {
            for (int i = 0; i < listView.SelectedItems.Count; i++)
            {
                listView.SelectedItems[i].Checked = true;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnNoCheckSel_Click(object sender, ClickEventArgs e)
        {
            for (int i = 0; i < listView.SelectedItems.Count; i++)
            {
                listView.SelectedItems[i].Checked = false;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnOK_Click(object sender, EventArgs e)
        {
            CheckedFields = new List<string>();
            foreach (ListViewItem item in listView.CheckedItems)
            {
                CheckedFields.Add(item.Text);
            }
            DialogResult = DialogResult.OK;
            Close();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCancel_Click(object sender, EventArgs e)
        {
            Close();
        }
    }
}
